package com.kf.common.mvi.viewmodel

import androidx.lifecycle.ViewModel
import com.kf.common.mvi.model.BaseModel
import com.kf.common.mvi.state.MutableContainer
import com.kf.common.mvi.state.RealContainer
import com.kf.common.mvi.state.UiState

abstract class BaseViewModel<M : BaseModel, STATE : UiState> : ViewModel() {
    protected var mModel: M

    private var state: STATE = createState()

    private var _mutableContainer: MutableContainer<STATE> = RealContainer(state)
    var mutableContainer: MutableContainer<STATE> = _mutableContainer
    abstract fun createState(): STATE
    abstract fun createModel(): M

    init {
        mModel = createModel()
    }

}